home *** CD-ROM | disk | FTP | other *** search
Lex Description | 1995-08-14 | 932 b | 43 lines |
- %{
- #include <ctype.h>
- #include "global.h"
- #include "y.tab.h"
-
- unsigned long line_num = 1;
- %}
-
- ID [A-Za-z_\.][A-Za-z0-9_]*(\.?)
- NUM ([0-9]+)|(0x[0-9a-fA-f]+)
- WS [ ][ ]*
- ES \\([abfnrtv'"?\\]|[0-7]{1,3}|x[0-9a-fA-F]+)
-
- %%
-
- {WS} ;
- "|".*$ ;
- ^"#".*$ ;
- {NUM} {
- yylval.num = strtoul(yytext, NULL, 0);
- return NUMBER;
- }
- {ID} {
- int n; char *s; static char buf[80];
-
- n = lookup(yytext, buf);
- if (n == 0) {
- yylval.str = strdup(yytext);
- s = yylval.str + yyleng - 1;
- if (*s == '.') *s = '_';
- return ID;
- } else {
- yylval.str = strdup(buf);
- return n;
- }
- }
- [0-9]: {yylval.str = strdup(yytext); return TMPLABEL;}
- [0-9][fb] {yylval.str = strdup(yytext); return TMPLABELfb;}
- \"([^"\n\\]|{ES})*\" {yylval.str = strdup(yytext); return STRING;}
- [-+(),:;@&^!*/%<>#=] return *yytext;
- "\n" {line_num++; return NL;}
- . yyerror("Illegal character %c", *yytext);
-